from bs4 import BeautifulSoup


hxml_str = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<ul>
    <li id="li1">li1</li>
    <li id="li2">li2</li>
    <li id="li3">li3</li>
</ul>

<ol>
    <li id="li1"><a href="https://www.baidu.com">百度</a></li>
    <li id="li2"><a href="https://www.jd.com">京东</a></li>
    <li id="li3"><a href="https://www.taobao.com">淘宝</a></li>
</ol>

<h1><a href="https://www.pdd.com">拼多多</a></h1>
</body>
</html>
"""

soup = BeautifulSoup(hxml_str)
# print(soup.prettify())
# print(type(soup),dir(soup))
# print(soup.title,type(soup.title),dir(soup.title))

# title = soup.title
# print(title.text,title.string,title.get_text())
# print(title.attrs)

# lis = soup.find_all("li")
# for li in lis:
#     print(type(li),li,li.text,li.attrs['id'])


# s = soup.find("a",attrs={"href":"https://www.pdd.com"})
# print(s,s.text)

# ol = soup.find("ol")
# lis = ol.find_all("li")
# for li in lis:
#     print(li.text)


# title = soup.css.select_one("title")
# print(title,type(title))
#
# lis = soup.css.select("ol  li")
# for li in lis:
#     print(li,type(li))
